<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
<title>后台管理系统</title>
<link rel="stylesheet"  href="__PUBLIC__/admin/laydate/need/laydate.css">
<script src="__PUBLIC__/admin/laydate/laydate.js"></script>
<link rel="stylesheet" href="__PUBLIC__/Admin/css/css.css">
<script src="__PUBLIC__/Admin/js/jquery-1.9.1.js"></script>
<script src="__PUBLIC__/Common/Layer/layer.js"></script>
<script src="__PUBLIC__/Common/Ueditor/ueditor.config.js"></script>
<script src="__PUBLIC__/Common/Ueditor/ueditor.all.min.js"> </script>
<script src="__PUBLIC__/Common/Ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="__PUBLIC__/Common/uploadPreview.min.js"></script>

<script>
   window.onload = function () { 
        new uploadPreview({ UpBtn: "pic_url", DivShow: "imgdiv", ImgShow: "imgShow" });
    }
</script>
<script>
    var ue = UE.getEditor('editor');
	var ue2 = UE.getEditor('editor2');
</script>
<script>
function check_form(){
	var title = $('#title').val();
	if(title == ''){
		layer.msg('活动名称不能为空');
		return false;
	}
	return true;
}
</script>
<script>
function copyUrl2(){
	var Url2=document.getElementById("biao1");
	Url2.select(); // 选择对象
	document.execCommand("Copy"); // 执行浏览器复制命令
	layer.msg('已复制好，可贴粘。');
}
function copyUrl3(){
	var Url3=document.getElementById("biao3");
	Url3.select(); // 选择对象
	document.execCommand("Copy"); // 执行浏览器复制命令
	layer.msg('已复制好，可贴粘。');
}
</script>
</head>
<body>

<div class="nav">
	<div class="nav_title">
    	<h4><img class="nav_img" src="__PUBLIC__/Admin/img/tab.gif" /><span class="nav_a">商品管理 -> 编辑商品</span></h4>
    </div>
</div>
<form name="form3" method="post" action="__SELF__" enctype="multipart/form-data" onSubmit="return check_form();">
<div class="list">
	  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="details" style=" margin-top:2px;">
      	  <tr>
	        <td colspan="2" style=" background:#E4EEFA;"><h3 style="margin-left:50px;">一、基本信息</h3></td>
       	  </tr>
        <tbody>
		  <tr>
	        <td width="20%"><div align="right">PC端 链接：</div></td>
	        <td width="80%"><input type="text" style="width:600px;" name="zhuanti_url" id="biao1" value="http://www.zzumall.com{:U('Home/Index/goods_details')}?id={$result.id}" readonly>
            <input type="button" onClick="copyUrl2()" style="padding:2px 15px; height:40px;" value="点击复制链接" />
            </td>
          </tr>

		<tr>
	        <td width="20%"><div align="right">移动端 链接：</div></td>
	        <td width="80%"><input type="text" style="width:600px;" name="zhuanti_url" id="biao3" value="http://www.zzumall.com{:U('Mobile/Goods/goods_goods')}?id={$result.id}" readonly>
            <input type="button" onClick="copyUrl3()" style="padding:2px 15px; height:40px;" value="点击复制链接" />
            </td>
          </tr>

		  <tr>
	        <td><div align="right">供应商分类：</div></td>
	        <td>
			<select name="shoper_id">
            	<option value="{$result.shoper_id}">{$result.mobile} ------ {$result.shoper_name}&nbsp;&nbsp;&nbsp;</option>

				<option value="">--------------</option>
            <foreach name="result_shoper" item="vo_shoper">
            	<option value="{$vo_shoper.id}">{$vo_shoper.mobile} ------ {$vo_shoper.shoper_name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            </foreach>

            </select>
            </td>
          </tr>
          <tr>
	        <td><div align="right">商品分类：</div></td>
	        <td>
			<select name="class_fid" id="class_id">
				
				<option value="{$result.class_fid}">{$class_fid_name.class_name}</option>
            	<option value="">----------</option>
            <foreach name="result_class" item="vo">
            	<option value="{$vo.id}">{$vo.class_name}</option>
            </foreach>
            </select>
			<select id="abc" name="class_id">
				<option value="{$result.class_id}">{$result.class_name}</option>
            	<option value="">----------</option>
            </select></td>
          </tr>
	      <tr>
	        <td width="20%"><div align="right">
	        <div align="right"><span style="color:#F00;">*</span> 标题：</div></td>
	        <td width="80%">
	          <input name="title" type="text" class="input" id="title" size="80" value="{$result.title}"> <span style="color:#00F;">长度请限制在 30 字以内</span>
            </td>
          </tr>
	      <tr>
	        <td width="20%"><div align="right">
	        <div align="right"><span style="color:#F00;">*</span> 商品简介：</div></td>
	        <td width="80%">
	          <input name="description" type="text" class="input" id="title" size="80" value="{$result.description}"> <span style="color:#00F;">长度请限制在 50 字以内</span>
            </td>
          </tr>
	      <tr>
	        <td><div align="right"><span style="color:#F00;">*</span>商品列表页单张主图：</div></td>
	        <td><span style="color:#F00;">建议图片尺寸请使用 （ 720 * 720 ） 像素</span>
	           	<div id="imgdiv">
                <img style="height:100px; width:100px; border-radius:4px;" src="{$result.pic_url}" />
	           	<img style="position:relative;top:6px;margin-right:30px;" id="imgShow" width="100" height="100" />
	           	<input type="file" name="pic_url[]" id="pic_url" /></div>   			
            </td>
          </tr>
	      <tr>
	        <td><div align="right">商品详情页图集：</div></td>
	        <td><span style="color:#F00;">建议图片尺寸宽度  （ 720 * 720 ）  像素</span><br/>
            
            <foreach name="result_tuji" item="vo_tuji">
            <a target="_blank" href="{$vo_tuji}">
            <img style="width:80px; height:80px; margin:5px 1px; border:1px solid #CCC;" src="{$vo_tuji}"></a>         
            </foreach>
            <br/>
            <span style="color:#00F; font-size:16px; margin:5px 0;"> [ 备注：更新图集会覆盖之前的图片，所以您需要再次添加之前需要的图片 ] </span><br/>
                        
            <input type="file" name="pic_tuji[]" /><input type="button" name="add_button" id="add_button" value="添加一行" style="padding:2px 15px; background:#00F; color:#FFF;">
            
			<div id="append_img"></div>
            
          </td>
		  </tr>
	      
	      <tr>
	        <td><div align="right">原价：</div></td>
	        <td><input type="text" style="color:#F00; font-weight:600;" name="price_old" id="price_old" value="{$result.price_old}">
            <span style="color:#00F;">元</span></td>
          </tr>
	      <tr>
	        <td><div align="right">现价：</div></td>
	        <td><input type="text" style="color:#F00; font-weight:600;" name="price_new" id="price_new" value="{$result.price_new}"> 
	        <span style="color:#00F;">元</span></td>
          </tr>
          <tr>
	        <td><div align="right">积分返利：</div></td>
	        <td><input type="text" style="color:#F00; font-weight:600;" name="fanli_jifen" id="fanli_jifen" value="{$result.fanli_jifen}"> 
	        </td>
          </tr>
	      <tr>
	        <td><div align="right">库存：</div></td>
	        <td><input type="text" style="color:#F00; font-weight:600;" name="kucun" id="kucun" value="{$result.kucun}">
            <span style="color:#00F;">件</span></td>
          </tr>
		  <tr bgcolor="#FEFEFE">
		    <td colspan="2" style="background:#F0F0F0;"><div align="center">商品规格</div></td>
          </tr>
          <tr>
          	<td colspan="2" id="guige">
             <foreach name="taocan" item="vo">
                 <div align="center">
                  <span>套餐 <input type="text" class="guige_input" name="guige_title[]" value="{$vo.guige_title}" style="width:240px; margin-bottom:5px;" /></span>
                  <span>套餐价￥ <input type="text" class="guige_input" name="guige_price_new[]" value="{$vo.guige_price_new}" /></span>
                  <!-- <span>库存/件 <input type="text" class="guige_input" name="guige_kucun[]" value="{$vo.guige_kucun}" /></span> -->
                  <span>重量/Kg <input type="text" class="guige_input" name="guige_zhongliang[]" value="{$vo.guige_zhongliang}" /></span>
                  <input type="button" value="删除" onClick="guige_del(this)" style="padding:0 20px;">
                 </div>
             </foreach>
             
             <div align="center">             
              <span>套餐 <input type="text" class="guige_input" name="guige_title[]" style="width:240px; margin-bottom:5px;" /></span>
              <span>套餐价￥ <input type="text" class="guige_input" name="guige_price_new[]" /></span>
          	  <!-- <span>库存/件 <input type="text" class="guige_input" name="guige_kucun[]" /></span> -->
          	  <span>重量/Kg <input type="text" class="guige_input" name="guige_zhongliang[]" /></span>
          	  <input type="button" value="添加" onClick="guige_add();" style="padding:0 20px; background:#06C; color:#FFF;">
        	 </div>

          	 <div id="guige_data"></div>       	    
            </td>
          </tr>
<script>
function guige_add(){
	var html = '<div align="center" style="margin-top:5px;">'+
' <span>套餐 <input type="text" class="guige_input" name="guige_title[]" style="width:240px; margin-bottom:5px;" /></span>'+
' <span>套餐价￥ <input type="text" class="guige_input" name="guige_price_new[]" /></span>'+
/*' <span>库存/件 <input type="text" class="guige_input" name="guige_kucun[]" /></span>'+*/
' <span>重量/Kg <input type="text" class="guige_input" name="guige_zhongliang[]" /></span>'+
' <input name="add_guige" type="button" value="删除" onClick="guige_del(this);" style="padding:0 20px;">'+
		'</div>';	
	$('#guige_data').append(html);	
}
</script>
<script>
function guige_del(_this){
	$(_this).parent().remove();
}
</script>
     <style>
     .guige_input{color:#F00; font-weight:600; width:60px; font-weight:500;}
     #guige span{ margin-right:10px;}
     </style>
		  <tr bgcolor="#FEFEFE">
          	<td colspan="2" style="background:#F0F0F0;"><div align="center">运费计算方式</div></td>
          </tr>
          <!-- <tr>
          	<td><div align="right">1千克以内：</div></td>
          	<td><input type="text" style="color:#F00; font-weight:600;" name="min_yunfei" value="{$result.min_yunfei}">
          	<span style="color:#00F;">元</span></td>
          </tr>
          <tr>
          	<td><div align="right">每续重1千克：</div></td>
          	<td><input type="text" style="color:#F00; font-weight:600;" name="add_yunfei" value="{$result.add_yunfei}">
          	<span style="color:#00F;">元</span></td>
          </tr>
          <tr>
          	<td><div align="right">最大费用：</div></td>
          	<td><input type="text" style="color:#F00; font-weight:600;" name="max_yunfei" value="{$result.max_yunfei}">
          	<span style="color:#00F;">元</span></td>
          </tr> -->
	      <tr>
	        <td><div align="right">全国包邮：</div></td>
	        <td>
			<input type="radio" name="min_yunfei" id="min_yunfei" value="1" <if condition="$result.min_yunfei == 1"> checked="checked" </if> >&nbsp;&nbsp;
              <laber for="min_yunfei">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="min_yunfei" id="min_yunfei2" value="0" <if condition="$result.min_yunfei == 0"> checked="checked" </if> >
	          <laber for="min_yunfei2">是</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ps：如果与江浙沪皖冲突，优先考虑江浙沪皖
            </td>
          </tr>
	      <tr>
	        <td><div align="right">江浙沪皖包邮：</div></td>
	        <td>
			<input type="radio" name="is_baoyou" id="is_baoyou" value="0" <if condition="$result.is_baoyou == 0"> checked="checked" </if> >&nbsp;&nbsp;
              <laber for="is_baoyou">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="is_baoyou" id="is_baoyou2" value="1" <if condition="$result.is_baoyou == 1"> checked="checked" </if> >
	          <laber for="is_baoyou2">是</label>
            </td>
          </tr>	
	      <tr>
	        <td><div align="right">商城首页顶部推荐：</div></td>
	        <td>
			<input type="radio" name="home_tuijian" id="rexiao" value="0" <if condition="$result.home_tuijian == 0"> checked="checked" </if> >&nbsp;&nbsp;
              <laber for="rexaio">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="home_tuijian" id="rexiao2" value="1" <if condition="$result.home_tuijian == 1"> checked="checked" </if> >
	          <laber for="rexaio2">是</label>
            </td>
          </tr>		  
	      <tr>
	        <td><div align="right">商城首页热销推荐：</div></td>
	        <td><input type="radio" name="rexiao" id="rexiao" value="0" <if condition="$result.rexiao == 0"> checked="checked" </if> >&nbsp;&nbsp;
              <laber for="rexaio">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="rexiao" id="rexiao2" value="1" <if condition="$result.rexiao == 1"> checked="checked" </if> >
	          <laber for="rexaio2">是</label>
            </td>
          </tr>
          <tr>
	        <td><div align="right">商城首页广告：</div></td>
	        <td><input type="radio" name="advert" id="advert" value="0" <if condition="$result.advert == 0"> checked="checked" </if> >&nbsp;&nbsp;
              <laber for="rexaio">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="advert" id="advert2" value="1" <if condition="$result.advert == 1"> checked="checked" </if> >
	          <laber for="advert2">是</label>
            </td>
          </tr>
          <tr>
	        <td><div align="right"> (详情页)同时购买推荐：</div></td>
	        <td><input type="radio" name="recommend" id="recommend" value="0" <if condition="$result.recommend == 0"> checked="checked" </if> >&nbsp;&nbsp;
              <laber for="rexaio">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="recommend" id="recommend2" value="1" <if condition="$result.recommend == 1"> checked="checked" </if> >
	          <laber for="recommend2">是</label>
            </td>
          </tr>
	      <tr>
	        <td><div align="right">整站上下架：</div></td>
	        <td><input type="radio" name="shangjia" id="shangjia" value="1" <if condition="$result.shangjia == 1"> checked="checked" </if> >&nbsp;&nbsp;
              <laber for="shangjia">上架</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="shangjia" id="shangjia2" value="0" <if condition="$result.shangjia == 0"> checked="checked" </if> >
	          <laber for="shangjia2">下架</label></td>
          </tr>
          <tr>
			  <td><div align="right">是否限购：</div></td>
			  <td><input type="radio" name="xiangou" id="xiangou" value="0" <if condition="$result.xiangou == 0"> checked="checked" </if> >&nbsp;&nbsp;
				  <laber for="xiangou">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					  <input type="radio" name="xiangou" id="xiangou2" value="1" <if condition="$result.xiangou == 1"> checked="checked" </if> >
					  <laber for="xiangou2">是</label></td>
		  </tr>




<tr>
			  <td><div align="right">限时抢购：</div></td>
			  <td><input type="radio" name="xianshi_status" id="xianshi" onclick="start()" value="0" <if condition="$result.xianshi_status == 0"> checked="checked" </if> >&nbsp;&nbsp;
				  <label for="xianshi">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					  <input type="radio" name="xianshi_status" onclick="over()" id="xianshi2" value="1" <if condition="$result.xianshi_status == 1"> checked="checked" </if> >
					  <label for="xianshi2">是</label>&nbsp;&nbsp;&nbsp;&nbsp;
				  <div id="time" style="margin-left:150px;">
					  开始抢购时间：<input type="text" class="laydate-icon" id="start" name="xianshi_start" value="{$result.xianshi_start}" >
					  结束抢购时间：<input type="text" class="laydate-icon" id="end" name="xianshi_over" value="{$result.xianshi_over}" >
					  <script>
						  var start = {
							  elem: '#start',
							  format: 'YYYY-MM-DD hh:mm:ss',
							  min: laydate.now(), //设定最小日期为当前日期
							  max: '2099-06-16 23:59:59', //最大日期
							  istime: true,
							  istoday: false,
							  choose: function(datas){
								  end.min = datas; //开始日选好后，重置结束日的最小日期
								  end.start = datas //将结束日的初始值设定为开始日
							  }
						  };
						  var end = {
							  elem: '#end',
							  format: 'YYYY-MM-DD hh:mm:ss',
							  min: laydate.now(),
							  max: '2099-06-16 23:59:59',
							  istime: true,
							  istoday: false,
							  choose: function(datas){
								  start.max = datas; //结束日选好后，重置开始日的最大日期
							  }
						  };
						  laydate(start);
						  laydate(end);
					  </script>
				  </div>
			  </td>
		  </tr>

		  <script>
			  var s=document.getElementById('xianshi');
			  var s2=document.getElementById('xianshi2');
			  if(s.checked==true){
				  $('#time').hide();
			  }
			  if(s2.checked==true){
				  $('#time').show();
			  }
			  function start(){
				  if(s.checked==true){
					  $('#time').hide();
				  }
			  }
			  function over(){
				  if(s2.checked==true){
					  $('#time').show();
				  }
			  }
		  </script>
		  </tr>




		  <tr>
	        <td><div align="right">是否开启团购：</div></td>
	        <td><input type="radio" name="is_tuangou" id="is_tuangou" value="1" <if condition="$result.is_tuangou == 1"> checked="checked" </if> >&nbsp;&nbsp;
              <laber for="is_tuangou">否</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="radio" name="is_tuangou" id="is_tuangou2" value="0" <if condition="$result.is_tuangou == 0"> checked="checked" </if> >
	          <laber for="is_tuangou2">是</label>
	        
	        <div>
	        团购开始时间：<input type="text" name="tg_begin_time" class="" />
	        团购结束时间：<input type="text" name="tg_end_time" class="" />
	        限购数量：<input type="text" name="tg_xiangou_num" />
	        </div>  
	          
	        </td>
          </tr>



		  <tr>
	        <td><div align="right">重量：</div></td>
	        <td><input name="zhongliang" type="text" id="zhongliang" class="input" value="{$result.zhongliang}">
			</td>
          </tr>	
	      <tr>
	        <td><div align="right">标签：</div></td>
	        <td><input name="keyword" type="text" id="keyword" class="input" size="80" value="{$result.keyword}">
            <span style="color:#00F;">多个标签，请用空格分隔开</span></td>
          </tr>
          <tr>
	        <td><div align="right">产品详情：</div></td>
	        <td><script id="editor" name="shuoming" type="text/plain" style="width:1000px;height:600px;">{$result.shuoming}</script></td>
          </tr>
	      <tr>
	        <td><div align="right">商品参数：</div></td>
	        <td><script id="editor2" name="guige" type="text/plain" style="width:1000px;height:600px;">{$result.guige}</script></td>
          </tr>
	      <tr>
	        <td><div align="right"></div></td>
	        <td>&nbsp;</td>
          </tr>
	      <tr>
	        <td><div align="right"></div></td>
	        <td>&nbsp;</td>
          </tr>
        </tbody>
  </table> 
</div>
<div class="footer">
	 <input type="hidden" name="id" value="{$result.id}" />
     <button type="submit" class="button" id="add_button" style="min-width:160px;" onclick="admin_add();">保存信息</button>
</div>
</form> 
<script>
$(function(){
	$('#add_button').click(function(){
		  var html = '<div><input type="file" name="pic_tuji[]" />'+
            		 '<input type="button" onClick="del_tuji(this);" value="删除" style="padding:2px 10px;"><div/>';
		$('#append_img').append(html);
	});
});

function del_tuji(event)
{
	event.parentNode.remove();
}

</script>
<script type="text/javascript">
	$(function() {
		$("#class_id").change(function() {
			var class_id = $("#class_id").val();
			$.ajax({
				data:'id='+class_id,
				type:"post",
				url:"{:U('Goods/ajaxgoods')}",
				success:function(msg) {
					console.log(msg)
					if(msg != 0){
						$("#abc").html('<option value="0">----------</option>');
						$.each(msg,function(k,v) {
								$("#abc").append('<option value='+v.id+'>'+v.class_name+'</option>');
						});
					}else{
						parent.layer.msg('没有2级分类，请添加！', {icon: 2, time: 2000 }); 
						$("#abc").html('<option value="0">----------</option>');
					}
				}
			});
		});
	});
</script>

</body>
</html>
